// dnSpy decompiler from Assembly-CSharp.dll class: InterstitialAds
using System;
using System.Collections;
//using GoogleMobileAds.Api;
using UnityEngine;

public class InterstitialAds : MonoBehaviour
{
	private void Awake()
	{
		if (null == InterstitialAds.instance)
		{
			UnityEngine.Object.DontDestroyOnLoad(base.gameObject);
			InterstitialAds.instance = this;
		}
		else
		{
			UnityEngine.Object.Destroy(base.gameObject);
		}
	}

	private void Start()
	{
		if (InterstitialAds.instance != this)
		{
			return;
		}
		this.InitInterstitial("ca-app-pub-3155579104247194/2122782493");
	}

	private void InitInterstitial(string id)
	{
		InterstitialAds.adMobInterstitialID = id;
		if (Application.platform == RuntimePlatform.Android || Application.platform == RuntimePlatform.IPhonePlayer)
		{
			InterstitialAds.Preload();
		}
	}

	public static void Show()
	{
		//if (InterstitialAds.adMobInterstitial != null && InterstitialAds.adMobInterstitial.IsLoaded())
		//{
		//	InterstitialAds.adMobInterstitial.Show();
		//}
	}

	private static void Preload()
	{
		UnityEngine.Debug.Log("Preloading AdMob Interstitial");
		//InterstitialAds.adMobInterstitial = new InterstitialAd(InterstitialAds.adMobInterstitialID);
		//InterstitialAds.adMobInterstitial.OnAdClosed += delegate(object sender, EventArgs e)
		//{
		//	UnityEngine.Debug.Log("AdMob Interstitial OnAdClosed");
		//	if (InterstitialAds.adMobInterstitial != null)
		//	{
		//		InterstitialAds.adMobInterstitial.Destroy();
		//		InterstitialAds.adMobInterstitial = null;
		//	}
		//	InterstitialAds.Preload();
		//};
		//InterstitialAds.adMobInterstitial.LoadAd(new AdRequest.Builder().AddKeyword("kids").AddKeyword("girls").AddKeyword("children").AddKeyword("dress up").AddKeyword("dress-up").AddKeyword("casual").AddKeyword("cake").AddKeyword("doctor").AddKeyword("salon").AddKeyword("farms").AddKeyword("pets").TagForChildDirectedTreatment(true).Build());
	}

	public static void ShowSometimes()
	{
		if (Time.time - InterstitialAds.timestampLastInterstitialShown > 60f)
		{
			InterstitialAds.Show();
			InterstitialAds.timestampLastInterstitialShown = Time.time;
		}
	}

	public static void ShowSometimesAfterDelay(float delaySecs)
	{
		if (null != InterstitialAds.instance)
		{
			InterstitialAds.instance.StartCoroutine(InterstitialAds.instance.ShowSometimesAfterDelayCoroutine(delaySecs));
		}
	}

	private IEnumerator ShowSometimesAfterDelayCoroutine(float delaySecs)
	{
		yield return new WaitForSeconds(delaySecs);
		InterstitialAds.ShowSometimes();
		yield break;
	}

	private void OnDestroy()
	{
		if (InterstitialAds.instance == this)
		{
			InterstitialAds.instance = null;
			//if (InterstitialAds.adMobInterstitial != null)
			//{
			//	InterstitialAds.adMobInterstitial.Destroy();
			//	InterstitialAds.adMobInterstitial = null;
			//}
		}
	}

	private static InterstitialAds instance;

	private const string ADMOB_INTERSTITIAL_ID_ANDROID = "ca-app-pub-3155579104247194/2122782493";

	private const string ADMOB_INTERSTITIAL_ID_IOS = "ca-app-pub-3155579104247194/2122782493";

	//private static InterstitialAd adMobInterstitial;

	private static string adMobInterstitialID = string.Empty;

	private static float timestampLastInterstitialShown;
}
